Skip to content

Conversation

@AlvaroVega
Copy link
Member

@AlvaroVega AlvaroVega commented May 10, 2021

issue #1036

  • Update related tests

The following tests are now not possible:

  • Update for an integer attribute with string expression
  • Update for a Float attribute with string expression
  • Update for a Null attribute with arithmetic expression
  • Update for a Null attribute with string expression
  • Update for a Boolean attribute with arithmetic expression
  • Update for a Boolean attribute with string expression

@AlvaroVega AlvaroVega changed the title [WIP] remove cast by type after apply expression remove cast by type after apply expression May 11, 2021
@AlvaroVega AlvaroVega changed the title remove cast by type after apply expression remove cast by type after apply JEXL expression May 11, 2021
@AlvaroVega AlvaroVega requested a review from fgalan May 11, 2021 15:04
}

newAttribute.value = applyExpression(attribute.expression, context, typeInformation);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any piece of documentation about this autocast feature that should be also removed/modified?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NTC

@@ -192,7 +192,7 @@ describe('Combine Jexl and legacy expressions (default JEXL)', function () {
.matchHeader('fiware-servicepath', 'gardens')
Copy link
Member

@fgalan fgalan May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have also a variant of this tests for ngsiv2

test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js

That file doesn't need modifications? (looking to CI results, it seems it doesn't, but I wonder why...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expressionCombinedTransformations-test.js includes tests which legacy and jexl expression, but not any of now not allowed cases:

Update for an integer attribute with string expression
Update for a Float attribute with string expression
Update for a Null attribute with arithmetic expression
Update for a Null attribute with string expression
Update for a Boolean attribute with arithmetic expression
Update for a Boolean attribute with string expression

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have had a look into this with more detail.

In test/unit/expressions/expressionCombinedTransformations-test.js (NGSIv1 variant) the only difference between old files (e.g. test/unit/examples/contextRequests/updateContextExpressionPlugin3.json) and new files (test/unit/examples/contextRequests/updateContextExpressionPlugin8.json) is that the old uses "value": "1040" ("stringfied") and the new "value": 1040 ("native").

On the other hand test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js (NGSIv2 variant) already uses the native way, e.g. see test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json.

Thus, I think that explains that only test/unit/expressions/expressionCombinedTransformations-test.js is changed in this PR but not test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js

NTC

});
});
});
// Deleted test by Issue #1034
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the "autocast after jexl processing" removal is definitive, maybe it's better to remove these tests instead of commenting. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 086a53f

@@ -1,3 +1,4 @@
- Fix: Do not transform attribute value using attribute type after apply expression plugin JEXL (#1034)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1034 is the number of the PR itself. I understand that in this case we don't have any issue, so the PR is cited, right?

Copy link
Member Author

@AlvaroVega AlvaroVega May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed with issue number 1036

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c6a1f70

.post(
'/v1/updateContext',
utils.readExampleFile('./test/unit/examples/contextRequests/updateContextExpressionPlugin3.json')
utils.readExampleFile('./test/unit/examples/contextRequests/updateContextExpressionPlugin3b.json')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating a new file (with the b suffix) I think it would be getter to edit the current ones. This way, the removal done in PR #995 would be easy (as there files are currently taken into account for the removal).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO is not possible edit current file, and should be splited to use in different tests.
Renamed files done into 8f3ea37

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I see (for instance https://github.com/telefonicaid/iotagent-node-lib/search?q=updateContextExpressionPlugin3).

I'll comment about the new files added in this PR on #995

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll comment about the new files added in this PR on #995

Here: #995 (comment)

NTC

Copy link
Member

@fgalan fgalan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fgalan fgalan merged commit 4599da1 into master May 13, 2021
@fgalan fgalan deleted the task/remove_casts_by_type_after_apply_expression branch May 13, 2021 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants